package com.jinzhi.jzweb.controller;


import java.util.*;
import java.util.stream.Collectors;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jinzhi.api.pojo.vo.TokenVO;
import com.jinzhi.common.type.EnumErrorCode;
import com.jinzhi.common.utils.ApiResult;
import com.jinzhi.common.utils.PasswdUtils;
import com.jinzhi.common.utils.UUIDUtils;
import com.jinzhi.jzapi.common.controller.ApittController;
import com.jinzhi.jzweb.domain.*;
import com.jinzhi.jzweb.pojo.ExaminationAnswerSheetComVO;
import com.jinzhi.jzweb.pojo.ExaminationAnswerSheetComVOS;
import com.jinzhi.jzweb.pojo.ModuleConfig.JzJinzhuanDispositionTopic;
import com.jinzhi.jzweb.pojo.OneLevelComVO;
import com.jinzhi.jzweb.pojo.StuSignUpComVo;
import com.jinzhi.jzweb.service.*;
import com.jinzhi.sys.domain.UserDO;
import com.jinzhi.sys.service.UserRoleService;
import com.jinzhi.sys.service.UserService;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.jinzhi.common.annotation.Log;
import com.jinzhi.common.base.BaseController;
import com.jinzhi.common.utils.Result;

/**
 *
 * <pre>
 * 考试答卷
 * 2023
 * </pre>
 * <small> 2023-05-05 15:11:09 | lance</small>
 */
@Controller
@RequestMapping("/jzweb/examinationAnswerSheetCom")
public class ExaminationAnswerSheetComController extends BaseController {
    @Autowired
    private ExaminationAnswerSheetComService examinationAnswerSheetComService;
    @Autowired
    private UserRoleService userRoleService;
    @Autowired
    private ExaminationAnswerSheetComService examinationAnswerSheetService;
    @Autowired
    private ExaminationPaperService examinationPaperService;
    @Autowired
    private StuSignUpComService stuSignUpService;
    @Autowired
    private ExaminationQuestionsService examinationQuestionsService;
    @Autowired
    private ExaminationBatchService examinationBatchService;
    @Autowired
    private ExaminationResultsComService resultsService;
    @Autowired
    private ExaminationResultsComService examinationResultsService;
    @Autowired
    private ApittController apittController;
    @Autowired
    private UserService userService;
    @Autowired
    private MarkService markService;

    /**
     * 查询理论考试批次
     * @return
     */
    @ResponseBody
    @PostMapping("/selEbatchIdLiLuen")
    public Result<List<ExaminationBatchDO>> selEbatchIdLiLuen(Long stuId,String competitionType) {
//        EntityWrapper wrapper =new EntityWrapper();
//        if (competitionType != null && competitionType != "" && competitionType != "null" && !competitionType.isEmpty() ){
//            wrapper.addFilter("{0} like CONCAT('%',competition_type,'%')",competitionType);
//        }
//        wrapper.eq("type",3); //查询理论批次
//        wrapper.orderBy("id",false);
        ExaminationBatchDO examinationBatchDO = new ExaminationBatchDO();
        examinationBatchDO.setCompetitionType(competitionType);
        examinationBatchDO.setStuId(stuId);
        List<ExaminationBatchDO> examinationBatchDOList = examinationBatchService.selectLists(examinationBatchDO);
        return Result.ok(examinationBatchDOList);
    }




    @PostMapping("/examinationAnswerSheetCom")
    @ResponseBody
    public Result<Object> infos(Model model,Long id1,Long  id2,Long cbatchId,String current, String number){
//        Long id1 = 1650432471143059458L;
        Wrapper<UserDO> uWrapper = new EntityWrapper<UserDO>();
        uWrapper.eq("id", id1);//id1是裁判id
        //根据裁判id查询出裁判的信息
        List<UserDO> userDOS = userService.selectList(uWrapper);
        //根据裁判信息查询出对应竞赛下的学员信息
        Wrapper<StuSignUpComDO> exWrapperstr = new EntityWrapper<StuSignUpComDO>();
        /*测试数据*/
        ExaminationAnswerSheetComVOS examinationAnswerSheetComVOS1 = new ExaminationAnswerSheetComVOS();
        examinationAnswerSheetComVOS1.setCbatchId(id2);
        if (userDOS.get(0).getCompetitionType() != null && userDOS.get(0).getCompetitionType() != ""){
            examinationAnswerSheetComVOS1.setCompetitionType(userDOS.get(0).getCompetitionType());
        }
        //查出学员及答卷信息
//        String current = "1";
//        String number = "10";
        Page<ExaminationAnswerSheetComVOS> page = stuSignUpService.listEsa( Integer.valueOf(current),Integer.valueOf(number),examinationAnswerSheetComVOS1);
        List<ExaminationAnswerSheetComVOS> records = page.getRecords();

        for (ExaminationAnswerSheetComVOS li : records) {
                    String vauel = StringEscapeUtils.unescapeJava(li.getAnswerList());//考生的答案信息
                    vauel.replaceAll("\r", "").replaceAll("\t", "").replaceAll("\n", "");
            try {
                    JSONArray jsonArray = JSONObject.parseArray(vauel);
                ExaminationAnswerSheetComVOS examinationAnswerSheetComVOS = new ExaminationAnswerSheetComVOS();
                for (int i = 0; i < jsonArray.size(); i++) {
                    JSONObject jsonObj = jsonArray.getJSONObject(i);//所有题题目订单type，id，value信息
                    String type = jsonObj.getString("type");//题目类型（type的值）
                    if (type.equals("4")) {//如果是4为案例分析
                            String id = jsonObj.getString("id");//考生id
                            ExaminationQuestionsDO examinationQuestionsDO = examinationQuestionsService.selectById(id);//题目信息
                            if (examinationQuestionsDO != null) {//如果不为空
                                li.setContent(examinationQuestionsDO.getIntroduce());//拿出题目描述
                            } else {
                                li.setContent("");//否则为空
                            }

                                li.setAnswerList(jsonObj.getString("value"));//考生答案listu.getId()
                                li.setState(jsonObj.getString("state"));//评分状态
                                li.setCourt(li.getCourt());////赛道(A赛场)

                            EntityWrapper<MarkDO> wrapper =new EntityWrapper<>();
                            if (!userDOS.get(0).getUsername().equals("超级管理员")){
                                wrapper.eq("referee_id",id1);
                            }
                            wrapper.eq("cbatch_id",cbatchId);
                            wrapper.eq("competition","A");
                            wrapper.eq("sign_id",li.getId());
                            wrapper.eq("status",0);
                            List<MarkDO> list1 = markService.selectList(wrapper);
                            for (int k = 0;k < list1.size();k++){
                                li.setUpdateScore(list1.get(k).getUpdateScore());//打分分数
                                li.setRefereeId(list1.get(k).getRefereeId());//裁判id
                                list1.get(k).setContent(examinationQuestionsDO == null?"":examinationQuestionsDO.getIntroduce());
                                list1.get(k).setAnswerList(jsonObj.getString("value"));
                                li.setMarkDOS(list1);
                            }
                            if (list1.size() <= 0){//如果没打分
                                if (!userDOS.get(0).getUsername().equals("超级管理员")){
                                    MarkDO markDO =new MarkDO();
                                    markDO.setContent(examinationQuestionsDO == null?"":examinationQuestionsDO.getIntroduce());
                                    markDO.setAnswerList(jsonObj.getString("value"));
                                    List<MarkDO> markDOS =new ArrayList<>();
                                    markDOS.add(markDO);
                                    li.setMarkDOS(markDOS);
                                }else {
                                    MarkDO  markDO =new MarkDO();
                                    markDO.setContent(examinationQuestionsDO.getIntroduce());
                                    markDO.setAnswerList(jsonObj.getString("value"));
                                    MarkDO markDO2 =new MarkDO();
                                    markDO.setContent(examinationQuestionsDO.getIntroduce());
                                    markDO.setAnswerList(jsonObj.getString("value"));
                                    MarkDO markDO3 =new MarkDO();
                                    markDO.setContent(examinationQuestionsDO.getIntroduce());
                                    markDO.setAnswerList(jsonObj.getString("value"));
                                    List<MarkDO> markDOS =new ArrayList<>();
                                    markDOS.add(markDO);
                                    markDOS.add(markDO2);
                                    markDOS.add(markDO3);
                                    li.setMarkDOS(markDOS);
                                }
                                li.setAnswerList(jsonObj.getString("value"));//考生答案listu.getId()
                                li.setState(jsonObj.getString("state"));//评分状态
                                li.setCourt(li.getCourt());////赛道(A赛场)

                            }


                        }
                    }
                li.setCbatchId(li.getCbatchId());//认证批次id
                li.setEbatchId(li.getEbatchId());
                li.setExamBatchId(li.getExamBatchId());//赛场id
                li.setStuId(li.getId());//学生id
                li.setNum2(li.getNum2());//学员二次加密数
//                li.add(examinationAnswerSheetComVOS);

            }catch (Exception e) {
                e.printStackTrace();
            }
        }

        page.setRecords(records);
        return Result.ok(page);
    }





    //    @GetMapping("/examinationAnswerSheetCom/{id}")
    @GetMapping()
    @RequiresPermissions("jzweb:examinationAnswerSheetCom:examinationAnswerSheetCom")
    String info(Model model) {
        return "jzweb/examinationAnswerSheetCom/examinationAnswerSheetCom";
    }


    /**
     * 一级管理员登录验证
     * @return
     */
    @Log("一级管理员现场改分")
    @PostMapping( "/oneLevelLogin")
    @ResponseBody
    public Result<String>  oneLevelLogin(String userName,String passWord){
        Wrapper<UserDO> uWrapper = new EntityWrapper<UserDO>().eq("username",userName);
        List<UserDO>  userDOS = userService.selectList(uWrapper);
        if(userDOS==null||userDOS.size()==0){
            return Result.fail("用户不存在");
        }else {
            List<String> organizationNewsDOS = userRoleService.selroleNameList(userDOS.get(0).getId());
            for(String name:organizationNewsDOS){
                if(!name.contains("管理员")){
                    return Result.fail("暂无权限！");
                }
            }
        }
        if(StringUtils.isBlank(passWord)){
            return Result.fail("密码错误！");
        }
        String salt = userDOS.get(0).getSalt();
        //    String encodePasswd = PasswdUtils.get(userDOS.get(0).getPassword(), salt);
        String encodePasswd1 = PasswdUtils.get(passWord, salt);
        if(encodePasswd1.equals(userDOS.get(0).getPassword())){
            return Result.ok();
        }else {
            return Result.fail("密码错误！");
        }


    }




    /**
     * 一级管理员现场改分
     * @return
     */
    @Log("一级管理员现场改分")
    @GetMapping( "/oneLevelUpdateCom")
    @ResponseBody
    @RequiresPermissions("jzweb:examinationAnswerSheetCom:oneLevelUpdateCom")
    public Result<String>  oneLevelUpdateCom(OneLevelComVO oneLevelComVO){
        List<ExaminationAnswerSheetComDO> examinationAnswerSheetDOs = examinationAnswerSheetService
                .findByKv("stu_sign_id", oneLevelComVO.getId());
        //获取考试批次
        //   ExaminationBatchDO examinationBatchDO = examinationBatchService.findOneByKv("id",oneLevelComVO.getExamBatchId());
        ExaminationResultsComDO examinationPaperDO = resultsService.findOneByKv("stu_sign_id", oneLevelComVO.getId());
        if(examinationPaperDO!=null){
            ExaminationResultsComDO examinationResultsDO = examinationPaperDO;

            if(oneLevelComVO.getFractionC()>0){
                examinationResultsDO.setScore3(oneLevelComVO.getFractionC());
            }
            if(oneLevelComVO.getFractionB()>0){
                examinationResultsDO.setScore2(oneLevelComVO.getFractionB()); }
            if(oneLevelComVO.getFractionA()>0){
                examinationResultsDO.setScore1(oneLevelComVO.getFractionA());
            }
            boolean b = examinationResultsService.updateById(examinationResultsDO);
            return b==true?Result.ok():Result.fail();
        }


        return Result.fail("修改失败，未进行阅卷！");
    }

    @ResponseBody
    @GetMapping("/list")
    @RequiresPermissions("jzweb:examinationAnswerSheetCom:examinationAnswerSheetCom")
    public Result<Page<ExaminationAnswerSheetComDO>> list(ExaminationAnswerSheetComDO examinationAnswerSheetComDTO){
        // 查询列表数据
        Page<ExaminationAnswerSheetComDO> page = examinationAnswerSheetComService.selectPage(getPage(ExaminationAnswerSheetComDO.class),
                examinationAnswerSheetComService.convertToEntityWrapper().orderBy("id", false));
        List list = new ArrayList();
        for (int i = 0; i < page.getRecords().size(); i++) {
            ExaminationAnswerSheetComDO obj = (ExaminationAnswerSheetComDO) page.getRecords().get(i);
            list.add(obj);
        }
        page.setRecords(list);
        return Result.ok(page);
    }

    @GetMapping("/add")
    @RequiresPermissions("jzweb:examinationAnswerSheetCom:add")
    String add(){
        return "jzweb/examinationAnswerSheetCom/add";
    }


    /**
     * 裁判A 打分
     * @return
     */
    @GetMapping("/fractionA")
    @ResponseBody
    @RequiresPermissions("jzweb:examinationAnswerSheetCom:fractionA")
    Result<String>  fractionA(Long id,Double fractionA,Long examBatchId){

        List<ExaminationAnswerSheetComDO> examinationAnswerSheetDOs = examinationAnswerSheetService
                .findByKv("stu_sign_id", id);
        //获取考试批次
        ExaminationBatchDO examinationBatchDO = examinationBatchService.findOneByKv("id",examBatchId);
        ExaminationResultsComDO examinationPaperDO = resultsService.findOneByKv("stu_sign_id", id);
        if(examinationPaperDO==null){


            ExaminationResultsComDO examinationResultsDO = new ExaminationResultsComDO();
            examinationResultsDO.setCbatchId(examinationBatchDO.getCbatchId());//认证批次id
            examinationResultsDO.setEbatchId(examBatchId);//考试批次id
            examinationResultsDO.setStuSignId(id);//考生信息id
            if(examinationAnswerSheetDOs == null){
                examinationResultsDO.setState(1);//缺考
            }else{

                examinationResultsDO.setState(0);//正常
            }
            Integer result = 0;
            ExaminationAnswerSheetComDO examinationAnswerSheetDO = null;
            if(examinationAnswerSheetDOs!=null && examinationAnswerSheetDOs.size()>0) {
                examinationAnswerSheetDO = examinationAnswerSheetDOs.get(0);
                if(examinationPaperDO!=null){
                    List<Long> idss = examinationQuestionsService.selIdList(examinationPaperDO.getId());
                    //试卷对应的试题，有试题才算分，没有直接0分处理；
                    if (idss != null && idss.size() > 0) {
                        if (examinationAnswerSheetDO != null) {
                            //有答卷才算分，没有直接返回0
                            result = results(examinationAnswerSheetDO.getAnswerList(), idss);//考试总分

                        }
                    }
                }

            }
            examinationResultsDO.setScore1(fractionA);
            examinationResultsDO.setTotalScore(result.doubleValue());//考试成绩
            boolean b = examinationResultsService.insert(examinationResultsDO);

            return b==true?Result.ok():Result.fail();
        }
        if(examinationPaperDO.getScore1()!=null){
            List<String> organizationNewsDOS = userRoleService.selroleNameList(this.getUserId());
            for(String name:organizationNewsDOS){
                if(name.contains("裁判")){
                    return Result.fail("您已经完成该考生已经完成评分！");
                }
            }
        }
        examinationPaperDO.setScore1(fractionA);
        boolean b = resultsService.updateById(examinationPaperDO);
        return b==true?Result.ok():Result.fail();
    }

    /**
     * 裁判B 打分
     * @return
     */
    @GetMapping("/fractionB")
    @ResponseBody
    @RequiresPermissions("jzweb:examinationAnswerSheetCom:fractionB")
    Result<String>  fractionB(Long id,Double fractionB,Long examBatchId){

        List<ExaminationAnswerSheetComDO> examinationAnswerSheetDOs = examinationAnswerSheetService
                .findByKv("stu_sign_id", id);
        //获取考试批次
        ExaminationBatchDO examinationBatchDO = examinationBatchService.findOneByKv("id",examBatchId);
        ExaminationResultsComDO examinationPaperDO = resultsService.findOneByKv("stu_sign_id", id);
        if(examinationPaperDO==null){

            ExaminationResultsComDO examinationResultsDO = new ExaminationResultsComDO();
            examinationResultsDO.setCbatchId(examinationBatchDO.getCbatchId());//认证批次id
            examinationResultsDO.setEbatchId(examBatchId);//考试批次id
            examinationResultsDO.setStuSignId(id);//考生信息id
            if(examinationAnswerSheetDOs == null){
                examinationResultsDO.setState(1);//缺考
            }else{

                examinationResultsDO.setState(0);//正常
            }
            Integer result = 0;
            ExaminationAnswerSheetComDO examinationAnswerSheetDO = null;
            if(examinationAnswerSheetDOs!=null && examinationAnswerSheetDOs.size()>0) {
                examinationAnswerSheetDO = examinationAnswerSheetDOs.get(0);
                if(examinationPaperDO!=null){
                    List<Long> idss = examinationQuestionsService.selIdList(examinationPaperDO.getId());
                    //试卷对应的试题，有试题才算分，没有直接0分处理；
                    if (idss != null && idss.size() > 0) {
                        if (examinationAnswerSheetDO != null) {
                            //有答卷才算分，没有直接返回0
                            result = results(examinationAnswerSheetDO.getAnswerList(), idss);//考试总分
                        }
                    }
                }

            }
            examinationResultsDO.setScore2(fractionB);
            examinationResultsDO.setTotalScore(result.doubleValue());//考试成绩
            boolean b = examinationResultsService.insert(examinationResultsDO);

            return b==true?Result.ok():Result.fail();
        }
        if(examinationPaperDO.getScore2()!=null){
            List<String> organizationNewsDOS = userRoleService.selroleNameList(this.getUserId());
            for(String name:organizationNewsDOS){
                if(name.contains("裁判")){
                    return Result.fail("您已经完成该考生已经完成评分！");
                }
            }
        }
        examinationPaperDO.setScore2(fractionB);
        boolean b = resultsService.updateById(examinationPaperDO);
        return b==true?Result.ok():Result.fail();
    }


    /**
     * 裁判B 打分
     * @return
     */
    @GetMapping("/fractionC")
    @ResponseBody
    @RequiresPermissions("jzweb:examinationAnswerSheetCom:fractionC")
    Result<String>  fractionC(Long id,Double fractionC,Long examBatchId){

        List<ExaminationAnswerSheetComDO> examinationAnswerSheetDOs = examinationAnswerSheetService
                .findByKv("stu_sign_id", id);
        //获取考试批次
        ExaminationBatchDO examinationBatchDO = examinationBatchService.findOneByKv("id",examBatchId);
        ExaminationResultsComDO examinationPaperDO = resultsService.findOneByKv("stu_sign_id", id);
        if(examinationPaperDO==null){

            ExaminationResultsComDO examinationResultsDO = new ExaminationResultsComDO();
            examinationResultsDO.setCbatchId(examinationBatchDO.getCbatchId());//认证批次id
            examinationResultsDO.setEbatchId(examBatchId);//考试批次id
            examinationResultsDO.setStuSignId(id);//考生信息id
            if(examinationAnswerSheetDOs == null){
                examinationResultsDO.setState(1);//缺考
            }else{

                examinationResultsDO.setState(0);//正常
            }
            Integer result = 0;
            ExaminationAnswerSheetComDO examinationAnswerSheetDO = null;
            if(examinationAnswerSheetDOs!=null && examinationAnswerSheetDOs.size()>0) {
                examinationAnswerSheetDO = examinationAnswerSheetDOs.get(0);
                if(examinationPaperDO!=null){
                    List<Long> idss = examinationQuestionsService.selIdList(examinationPaperDO.getId());
                    //试卷对应的试题，有试题才算分，没有直接0分处理；
                    if (idss != null && idss.size() > 0) {
                        if (examinationAnswerSheetDO != null) {
                            //有答卷才算分，没有直接返回0
                            result = results(examinationAnswerSheetDO.getAnswerList(), idss);//考试总分

                        }
                    }
                }

            }
            examinationResultsDO.setScore3(fractionC);
            examinationResultsDO.setTotalScore(result.doubleValue());//考试成绩
            boolean b = examinationResultsService.insert(examinationResultsDO);
            return b==true?Result.ok():Result.fail();
        }
        if(examinationPaperDO.getScore3()!=null){
            List<String> organizationNewsDOS = userRoleService.selroleNameList(this.getUserId());
            for(String name:organizationNewsDOS){
                if(name.contains("裁判")){
                    return Result.fail("您已经完成该考生已经完成评分！");
                }
            }
        }
        examinationPaperDO.setScore3(fractionC);
        boolean b = resultsService.updateById(examinationPaperDO);
        return b==true?Result.ok():Result.fail();
    }


    private Integer results(String answers,List<Long> idss) {
        Integer results = 0;
        if(StringUtils.isNotBlank(answers)){
            net.sf.json.JSONArray jsonArray2 = net.sf.json.JSONArray.fromObject(answers);
            for(int i = 0;i<jsonArray2.size();i++){
                if(idss.indexOf(Long.parseLong(jsonArray2.getJSONObject(i).getString("id"))) > -1){
                    ExaminationQuestionsDO examinationQuestionsDO = examinationQuestionsService.selectById(Long.parseLong(jsonArray2.getJSONObject(i).getString("id")));
                    if(!jsonArray2.getJSONObject(i).containsKey("value"))continue;
                    if (examinationQuestionsDO.getType() == 0 || examinationQuestionsDO.getType() == 2) {//单选题和判断题，答案唯一，可以不用拆解了
                        if (examinationQuestionsDO.getAnswers().equals(jsonArray2.getJSONObject(i).getString("value"))) {
                            results = results + examinationQuestionsDO.getScore();
                        }
                    } else if (examinationQuestionsDO.getType() == 1) {//多选题因为答案有多个，需要循环判断一下是否包含该答案
                        String[] ssb = jsonArray2.getJSONObject(i).getString("value").split(";;");
                        String answer = "";
                        for (int n = 0; n < ssb.length; n++) {
                            if (answer == "") {
                                answer = ssb[n];
                            } else {
                                answer = answer + ";;" + ssb[n];
                            }
                        }

                        if (examinationQuestionsDO.getAnswers().equals(answer)) {
                            results = results + examinationQuestionsDO.getScore();
                        }

                    }
                }
            }
        }

        return results;
    }


    @GetMapping("/edit/{id}")
    @RequiresPermissions("jzweb:examinationAnswerSheetCom:edit")
    String edit(@PathVariable("id") Long id,Model model) {


        ExaminationAnswerSheetComDO examinationAnswerSheetCom = examinationAnswerSheetComService.selectById(id);
        ExaminationAnswerSheetComVO answerSheetComVO = new ExaminationAnswerSheetComVO();
        String vauel = examinationAnswerSheetCom.getAnswerList();
        JSONArray jsonArray = JSONObject.parseArray(vauel);
        for (int i = 0; i < jsonArray.size(); i++) {
            JSONObject jsonObj = jsonArray.getJSONObject(i);
            String type = jsonObj.getString("type");
            if (type.equals("4")) {
                StuSignUpComDO stuSignUpComDO = stuSignUpService.selectById(examinationAnswerSheetCom.getStuSignId());
                if (stuSignUpComDO != null) {
                    answerSheetComVO.setAnswerList(jsonObj.getString("value"));
                    answerSheetComVO.setState(stuSignUpComDO.getState().toString());
                    answerSheetComVO.setNum2(stuSignUpComDO.getNum2());
                    answerSheetComVO.setCourt(stuSignUpComDO.getCourt());
                    answerSheetComVO.setId(stuSignUpComDO.getId());
                    answerSheetComVO.setExamBatchId(stuSignUpComDO.getCbatchId());
                }
                model.addAttribute("answerSheetComVO", answerSheetComVO);
            }
        }
        return "jzweb/examinationAnswerSheetCom/edit";
    }
    @Log("添加考试答卷")
    @ResponseBody
    @PostMapping("/save")
    @RequiresPermissions("jzweb:examinationAnswerSheetCom:add")
    public Result<String> save( ExaminationAnswerSheetComDO examinationAnswerSheetCom){
        examinationAnswerSheetComService.insert(examinationAnswerSheetCom);
        return Result.ok();
    }

    @Log("修改考试答卷")
    @ResponseBody
    @RequestMapping("/update")
    @RequiresPermissions("jzweb:examinationAnswerSheetCom:edit")
    public Result<String>  update( ExaminationAnswerSheetComDO examinationAnswerSheetCom){
        boolean update = examinationAnswerSheetComService.updateById(examinationAnswerSheetCom);
        return update ? Result.ok() : Result.fail();
    }

    @Log("删除考试答卷")
    @PostMapping( "/remove")
    @ResponseBody
    @RequiresPermissions("jzweb:examinationAnswerSheetCom:remove")
    public Result<String>  remove( Long id){
        examinationAnswerSheetComService.deleteById(id);
        return Result.ok();
    }

    @Log("批量删除考试答卷")
    @PostMapping( "/batchRemove")
    @ResponseBody
    @RequiresPermissions("jzweb:examinationAnswerSheetCom:batchRemove")
    public Result<String>  remove(@RequestParam("ids[]") Long[] ids){
        examinationAnswerSheetComService.deleteBatchIds(Arrays.asList(ids));
        return Result.ok();
    }

}
